package com.betterjr.modules.profit;

import com.alibaba.dubbo.config.annotation.Reference;
import com.betterjr.common.web.Servlets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

import static com.betterjr.common.web.ControllerExceptionHandler.exec;

/**
 * Created by chenlj on 2018/6/27
 */
@Controller
@RequestMapping(value = "/Scf/LoanShare")
public class ScfLoanShareController {
    private static final Logger logger = LoggerFactory.getLogger(ScfLoanShareController.class);

    @Reference(interfaceClass = IScfProfitService.class)
    private  IScfProfitService scfProfitService;

    @RequestMapping(value = "/queryLoanShareList", method = RequestMethod.POST)
    public @ResponseBody String queryLoanShareList(HttpServletRequest request, int flag, int pageNum, int pageSize) {
        Map<String, Object> map = Servlets.getParametersStartingWith(request, "");
        logger.info("分页查询分润费，入参：" + map.toString());
        return exec(() -> scfProfitService.webQueryLoanShareList(map, flag, pageNum, pageSize), "查询分润费失败" ,logger);
    }

    @RequestMapping(value = "/saveUpdateLoanShareStatus", method = RequestMethod.POST)
    public @ResponseBody String saveUpdateLoanShareStatus(HttpServletRequest request) {
        Map<String, Object> map = Servlets.getParametersStartingWith(request, "");
        logger.info("改变分润费明细状态，入参：" + map.toString());
        return exec(() -> scfProfitService.webSaveConfirmLoanShareStatus(map),"改变分润费明细状态失败",logger);
    }
}
